home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig05_06.jar / Ch05 / Fig05_06 / Fig05_06.cpp next >
C/C++ Source or Header  |  1997-10-14  |  430b  |  22 lines

  1. // Fig. 5.6: fig05_06.cpp
  2. // Cube a variable using call-by-value
  3. #include <iostream.h>
  4.  
  5. int cubeByValue( int );   // prototype
  6.  
  7. int main()
  8. {
  9.    int number = 5;
  10.  
  11.    cout << "The original value of number is " << number;
  12.    number = cubeByValue( number );
  13.    cout << "\nThe new value of number is " << number << endl;
  14.    return 0;
  15. }
  16.  
  17. int cubeByValue( int n )
  18. {
  19.    return n * n * n;   // cube local variable n
  20. }
  21.  
  22.